package com.Helper;
import java.sql.SQLException;

public class ReservationInfo extends Info
{
	public int num;
	public String firstName = null;
	public String lastName = null;
	public String seat = null;
	public float paidPrice;
	public int paidPoint;
	public String meal = null;
	public String flightID = null;
	public String username = null;
	public String status = null;
	
	public String airline = null;
	public String departing = null;
	public String arriving = null;
	public String departingTime = null;
	public String arrivingTime = null;
	public String price = null;
	public String capacity = null;
	public String distance = null;
	public String imgName = null;
	
	private static final String imgPath = "/Website/icon/";
	
	public void GetFlightInfo() throws SQLException
	{
		ConnectDB();
		FlightHelper.Setup(connection);
		FlightInfo info = FlightHelper.GetSelectedFlights(flightID);
		
		airline = info.airline;
		departing = info.departureLocation;
		arriving = info.arrivalLocation;
		departingTime = info.departureTime;
		arrivingTime = info.arrivalTime;
		price = Float.toString(info.price);
		capacity = Integer.toString(info.capacity);
		distance = Float.toString(info.distance);
	}
	
	public String getImage()
	{
		imgName = imgPath;
		if (airline.equals("Air Canada")) imgName += "aircanadalogo.png";
		else if (airline.equals("Air China")) imgName += "airchinalogo.png";
		
		return imgName;
	}
	
	public String getFlightID()
	{
		return flightID;
	}
	
	public String getDistance()
	{
		return distance;
	}
	
	public String getUsername()
	{
		return username;
	}
	
	public int getNum()
	{
		return num;
	}
	
	public String getFirstName()
	{
		return firstName;
	}
	
	public String getLastName()
	{
		return lastName;
	}
	
	public String getFullName()
	{
		String name = firstName + " " + lastName;
		return name;
	}
	
	public String getSeat()
	{
		return seat;
	}
	
	public float getPaidPrice()
	{
		return paidPrice;
	}
	
	public int getPaidPoint()
	{
		return paidPoint;
	}
	
	public float getFullPrice() throws SQLException
	{
		ConnectDB();
		float price = 0;
		try 
		{
			PaymentHelper.Setup(connection);
			price = PaymentHelper.GetPriceForSeat(seat, flightID);
		} 
		catch (Exception e) 
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return price;
	}
	
	public String getMeal()
	{
		return meal;
	}
	
	public String getAirline()
	{
		return airline;
	}
	
	public String getDeparting()
	{
		return departing;
	}
	
	public String getDepartingDate()
	{
		String s = departingTime.substring(0, 10);
		return s;
	}
	
	public String getDepartingTime()
	{
		String s = departingTime.substring(11, 16);
		return s;
	}
	
	public String getArriving()
	{
		return arriving;
	}
	
	public String getArrivingDate()
	{
		String s = arrivingTime.substring(0, 10);
		return s;
	}
	
	public String getArrivingTime()
	{
		String s = arrivingTime.substring(11, 16);
		return s;
	}
	
	public String getPrice()
	{
		return price;
	}
	
	public String getCapacity()
	{
		return capacity;
	}
}
